package com.ruoyi.api.controller;

import cn.hutool.json.JSONUtil;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.standingbook.v2toilet.bill.BillReceiveBean;
import com.ruoyi.standingbook.v2toilet.logic.V2ExtendAsyncService;
import com.ruoyi.standingbook.v2toilet.logic.V2ExtendProcessService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 人员和车辆轨迹数据统计汇总
 *
 * @author cc
 * @date 2023-04-28
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/stat/v2/toilet")
@Slf4j
public class V2ToiletApiController extends BaseController {
    private final V2ExtendProcessService v2ToiletExcelService;
    private final V2ExtendAsyncService apiLogService;

    /**
     * 接收工单处理情况
     */
    @PostMapping("receive/bill")
    @ResponseBody
    public R<Void> billReceive(@RequestBody String json) {
        //        V2ToiletBillBo bo = JSON.parseObject(json, V2ToiletBillBo.class);

        BillReceiveBean bo = JSONUtil.toBean(json, BillReceiveBean.class, true);
        apiLogService.saveApiLog("V2ToiletApiController.billReceive", false, json);
        return v2ToiletExcelService.receiveBill(bo);
    }
}
